{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Amortized posterior inference on Gaussian example"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Note, you can find the original version of this notebook at [https://github.com/sbi-dev/sbi/blob/main/tutorials/01_gaussian_amortized.ipynb](https://github.com/sbi-dev/sbi/blob/main/tutorials/01_gaussian_amortized.ipynb) in the `sbi` repository."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In this tutorial, we will demonstrate how `sbi` can infer an amortized posterior for a simple toy model with a uniform prior and Gaussian likelihood."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "import numpy as np\n",
    "\n",
    "from sbi import utils as utils\n",
    "from sbi import analysis as analysis\n",
    "from sbi.inference.base import infer"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Defining prior, simulator, and running inference\n",
    "Say we have a 3-dimensional parameter space, and the prior is uniformly distributed between `-2` and `2` in each dimension, i.e. $\\theta \\in [-2,2], y\\in [-2,2], z \\in [-2,2]$."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "num_dim = 3\n",
    "prior = utils.BoxUniform(low=-2 * torch.ones(num_dim), high=2 * torch.ones(num_dim))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Our simulator takes the input parameters, adds `1.0` in each dimension, and then adds some Gaussian noise:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "def linear_gaussian(theta):\n",
    "    return theta + 1.0 + torch.randn_like(theta) * 0.1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can then run inference (either with the simple interface or with the flexible interface):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "posterior = infer(linear_gaussian, prior, \"SNPE\", num_simulations=1000)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Amortized inference\n",
    "Note that we have not yet provided an observation to the inference procedure. In fact, we can evaluate the posterior for different observations without having to re-run inference. This is called amortization. An amortized posterior is one that is not focused on any particular observation. Naturally, if the diversity of observations is large, any of the inference methods will need to run a sufficient number of simulations for the resulting posterior to perform well across these diverse observations."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's say we have two observations `x_o_1 = [0,0,0]` and `x_o_2 = [2,2,2]`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "x_o_1 = torch.zeros(3,)\n",
    "x_o_2 = 2.0 * torch.ones(3,)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can draw samples from the posterior given `x_o_1` and then plot them:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "ca7655f9bf1942beb4bb5270b5df9a38",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Drawing 10000 posterior samples:   0%|          | 0/10000 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAS0AAAFJCAYAAADOhnuiAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAdiElEQVR4nO3da4xcZ53n8e//nFO3bl86jhNw7GQ87Myyq2UhXAZ2MWiFByQuQok0jASDGI3EGyRWAml5YYHEZpEQfjUzb3Y1QhkUXqCFHQHSaAOLYIzE4CzZhGwgtyEbMiaOA4TYbrvddTuX/744p7qr27d2d7lPPV2/j9T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tGrS8z61Buz/xPkzj2pOnqoUhAqn3UvwH8jHLs6ZEJHfoA8NVqT/kI+B/u/j8ndOyJ0i4PIhIUdQ9FJCgKLREJikJLRIKi0BKRoCi0RCQoCi0RCYpCS0SCotASkaD8f8stDy8QmZrjAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 360x360 with 9 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "posterior_samples_1 = posterior.sample((10000,), x=x_o_1)\n",
    "\n",
    "# plot posterior samples\n",
    "_ = analysis.pairplot(\n",
    "    posterior_samples_1, limits=[[-2, 2], [-2, 2], [-2, 2]], figsize=(5, 5)\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As it can be seen, the posterior samples are centered around `[-1,-1,-1]` in each dimension. \n",
    "This makes sense because the simulator always adds `1.0` in each dimension and we have observed `x_o_1 = [0,0,0]`."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Since the learned posterior is amortized, we can also draw samples from the posterior given the second observation without having to re-run inference:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "96dc0d5e0eb84a4bb3339f464754fc17",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Drawing 10000 posterior samples:   0%|          | 0/10000 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAS0AAAFJCAYAAADOhnuiAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAg9UlEQVR4nO3dbYxkV33n8e//3HvroXvaHoPt2IyddWA3vFhETEgAYZAWJ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mb2nufykmX2sWWr0iJn9opn9rZn9wMx+Z/sxPbnUXC2an4Us4lRoibSImb0WeC9wN/AO4Jevcven3P1uUrX5/cB7gDcAOw79zCwzs28AzwFfdPcr7rQwTwotkXZ5M/BZd19vdkL43FXuO/ndY8DX3P2iu/8UGJnZye13dve6Cbk7gNeZ2TW/OHUeFFoiR9eo+TdOXZ5cv+J8truvAl8C3nZgLdsHhZZIu3wZeLeZ9Zutid81i4Oa2S2T3peZ9UnbM/+/WRx71nT2UKRFmn3UPw18kzT39PCMDn078KlmT/kA/E93/+sZHXumtMuDiLSKhoci0ioKLRFpFYWWiLSKQktEWkWhJSKtotASkVZRaIlIqyi0RKRV/j/G0RutS9IhtwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 360x360 with 9 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "posterior_samples_2 = posterior.sample((10000,), x=x_o_2)\n",
    "\n",
    "# plot posterior samples\n",
    "_ = analysis.pairplot(\n",
    "    posterior_samples_2, limits=[[-2, 2], [-2, 2], [-2, 2]], figsize=(5, 5)\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "So, if we observed `x_o_2 = [2,2,2]`, the posterior is centered around `[1,1,1]` -- again, this makes sense because the simulator adds `1.0` in each dimension."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
